<extend name="Base/common"/>
<block name="body">
	<div class="span9 page_message">
		<section id="contents">
			<include file="Addons/_nav"/>
			<div class="tab-content">
				<h3>与 {$toUser.nickname} 的聊天</h3>
			</div>
			<!-- 数据列表 -->
			<div class="data-table">

				<div class="table-striped">
					<table class="message_list" cellspacing="0">
						<thead>
						<tr>
							<th colspan="3">
								<div class="msg_tab">
									<a class="txt current" href="javascript:;">文本消息</a>
									<a class="appmsg" href="javascript:;">图文消息</a>
									<a class="image" href="javascript:;">图片消息</a>
								</div>
								<form id="form" action="{:U('reply')}" method="post"
								      class="form-horizontal form-center">
									<input type="hidden" name="msg_type" value="text"/>
									<input type="hidden" class="text input-large" name="openid" value="{:I('openid')}">
									<label class="textarea input-large">
										<textarea name="content" placeholder="请输入要发送的文本"></textarea>

										<div style="display:none" class="appmsg_area" id="appmsg_area">
											<input type="hidden" name="appmsg_id" value="0"/>
											<a class="select_appmsg" href="javascript:;"
											   onClick="$.WeiPHP.openSelectAppMsg('{:U('/Home/Material/material_data')}',selectAppMsgCallback)">选择图文</a>

											<div class="appmsg_wrap"></div>
											<a class="delete" href="javascript:;">删除</a>
										</div>
										<div style="display:none;margin:0 10px 10px 0; background:#ddd; padding:6px;height:204px; width:930px;"
										     class="msg_image controls uploadrow2" title="点击修改图片" rel="image">
											<input type="file" id="upload_picture_image">
											<input type="hidden" name="image" id="cover_id_image" value="0"/>

											<div class="upload-img-box" style="display:none; top:6px; left:6px;">
												<div class="upload-pre-item2"><img width="100" height="100" src=""/>
												</div>
											</div>
										</div>
									</label>
									<!--
									 <div class="action_type">
										 <a class="action_item face" href="javascript:;" title="表情">&nbsp;</a>
										<a class="action_item link" href="javascript:;" title="连接">&nbsp;</a>
										<div class="action_item picture" href="javascript:;" title="图片">
											<div class="controls uploadrow2" title="点击修改图片" rel="pic">
											  <input type="file" id="upload_picture_pic">
											  <input type="hidden" name="pic" id="cover_id_pic" value="0"/>
											  <div class="upload-img-box">

												  <div class="upload-pre-item2"><img width="100" height="100" src=""/></div>

											  </div>
										  </div>
										</div>
										<a class="action_item article" href="javascript:;" title="图文">&nbsp;</a>
									 </div>
									 -->
									<button class="btn submit-btn ajax-post" id="submit" type="submit"
									        target-form="form-horizontal">回 复
									</button>
								</form>
							</th>
						</tr>
						</thead>
						<!-- 列表 -->
						<tbody>
						<volist name="list_data" id="vo">
							<tr>
								<td width="60%" class="user">
									<notempty name="vo[user][headimgurl]">
										<img width="50" src="{$vo.user.headimgurl}"/>
										<else/>
										<img width="50" src="__IMG__/default.png"/>
									</notempty>
									<div class="u_info">
										<notempty name="vo[user][headimgurl]">
											<p class="name">{$vo.user.nickname}</p>
											<else/>
											<p class="name">{$vo.openid}</p>
										</notempty>

										<p class="msg">{$vo.Content}</p>
									</div>
								</td>
								<td width="25%" valign="top">{$vo.CreateTime|time_format}</td>
								<td width="15%" valign="top">
									<eq name="vo.collect" value="0"><a href="javascript:void(0)"
									                                   onclick="set_status({$vo.id},'collect', 1)">收藏</a>
										<else/>
										<a href="javascript:void(0)"
										   onclick="set_status({$vo.id},'collect', 0)">取消收藏</a></eq>
									<eq name="vo.deal" value="0"><a href="javascript:void(0)"
									                                onclick="set_status({$vo.id},'deal', 1)">设为待处理</a>
										<else/>
										<a href="javascript:void(0)"
										   onclick="set_status({$vo.id},'deal', 0)">取消待处理状态</a></eq>
								</td>
							</tr>
						</volist>
						</tbody>
					</table>
				</div>
			</div>
			<div class="page"> {$_page|default=''}</div>
		</section>
	</div>
</block>
<block name="script">
	<script type="text/javascript">
		function set_status(id, field, val) {
			$.post("{:U('set_status')}", {id: id, field: field, val: val}, function () {
				location.reload();
			})
		}
		$(function () {
			//初始化上传图片插件
			initUploadImg({width: 308, height: 200});
			$('.uploadify-button').css('background-color', '#ccc')
		})
		$('.msg_tab .txt').click(function () {
			//纯文本
			$(this).addClass('current').siblings().removeClass('current');
			$('input[name="msg_type"]').val('text');
			$('textarea[name="content"]').show().siblings().hide();
		})
		$('.msg_tab .appmsg').click(function () {
			//图文消息
			$(this).addClass('current').siblings().removeClass('current');
			$('input[name="msg_type"]').val('appmsg');
			$('#appmsg_area').show().siblings().hide();
		})
		$('.msg_tab .image').click(function () {
			//图片消息
			$(this).addClass('current').siblings().removeClass('current');
			$('input[name="msg_type"]').val('image');
			$('.msg_image').show().siblings().hide();
		})
		$('.appmsg_area .delete').click(function () {
			$('.appmsg_wrap').html('').hide();
			$('.select_appmsg').show();
			$('.appmsg_area .delete').hide();
			$('input[name="appmsg_id"]').val(0);
		})
		function selectAppMsgCallback(_this) {
			$('.appmsg_wrap').html($(_this).html()).show();
			$('.select_appmsg').hide();
			$('.appmsg_area .delete').show();
			$('input[name="appmsg_id"]').val($(_this).data('id'));
			$.Dialog.close();
		}

	</script>
</block>
